package com.liruo.treasureattic.autoconfiguration.mybatis;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.context.annotation.Bean;

/**
 * @Author:liruo
 * @Date:2022-11-24-15:07:19
 * @Desc
 */
@AutoConfiguration
public class MyBatisAutoconfig {
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        //
        MybatisPlusInterceptor multiInterceptor = new MybatisPlusInterceptor();
        //向Mybatis过滤器链中添加分页拦截器
        PaginationInnerInterceptor paginationInnerInterceptor = new PaginationInnerInterceptor(DbType.MYSQL);
        multiInterceptor.addInnerInterceptor(paginationInnerInterceptor);
        return multiInterceptor;
    }
}
